
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>生成100个DIV</title>
</head>

<body>

<script>

/*
0%3		= 0
1%3		= 1
2%3		=	2
3%3		= 0
4%3		= 1
5%3		= 2
……
*/

/*
	Math.floor(3.4);		向下取整	=> 3
	Math.floor(1.1);		向下取整	=> 1
	Math.floor(1.9);		向下取整	=> 1
*/

// for (var i=0; i<5; i++) {
// 	// alert( i%3 );
// }

var len = 100;
var str = '';
var arr =  ['tan','skyblue','yellowgreen','orange','pink'];
for (var i=0; i<len; i++) {
	/*
		0		0
		1		0.1
		2		0.2
		3		0.3
		
		10	55	1
		11	55	1.1
		12	55	1.2
		
		11/10		=>  1.1
	*/	
	str += '<div style="top:' + Math.floor(i/10)*55 + 'px; left:' + i%10*55 + 'px; position:absolute; width:50px; height:50px; background:'+ arr[i%arr.length] +';"></div>';
}
document.body.innerHTML = str;

</script>

</body>
</html>
